/**
 * 载入项目引导文件
 */
require('./bootstrap');

window.Vue = require('vue');

//标签输入，官方网址：http://www.vue-tags-input.com/#/
import InputTag from 'vue-input-tag';
//时间控件，官网：https://github.com/weifeiyue/vue-datepicker-local
import VueDatepickerLocal from 'vue-datepicker-local'
//树形select选择框
import Treeselect from '@riophae/vue-treeselect'
// import the styles
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

Vue.component('MaterialSelecter', require('../components/MaterialSelecter.vue'));
Vue.component('MaterialPreview', require('../components/MaterialPreview.vue'));

let box;

const app = new Vue({
    el: '#wrapper',
    data: {
        massData:page_params.data_mass,
        tag_list:page_params.data_taglist,
        catNormalizer(node){
            return {
                id:node.wx_tag_id,
                label:node.tag_name,
                children: node.children,
            }
        },
    },
    methods:{
        choiceMaterial:function(materialData){//选择素材回调
            this.massData.material = materialData;
        },
        showMaterialSelecter:function () {
            this.$refs.materialSelecterBox.showBox();
        },
        save:function(){
            let loadBox = layer.load(1, {
                shade: [0.3,'#fff'] //0.1透明度的白色背景
            });
            let url_save = this.massData.id ? page_params.url_edit : page_params.url_add;
            utils.ajaxPost(url_save, this.massData, (response, data) => {
                layer.close(loadBox);
                utils.showToastr(response.data, 'go');
            });
        },
    },
    components: {
        InputTag,VueDatepickerLocal,Treeselect
    },
});